package egovframework.npqs.pqi.mobile.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import egovframework.rte.psl.dataaccess.EgovAbstractDAO;

@Repository("mobileDAO")
public class MobileDAO extends EgovAbstractDAO{

	@SuppressWarnings("unchecked")
	public List<Map<String,String>> jsonReceiverList(Map<String,String> map)throws Exception {

		return list("mobile.service.selectReqstInfo", map);

	}
	
	/*로그인 정보 담아두기*/
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectCommonCode(Map paramMap)throws Exception {
		
		String QueryID="";

			QueryID="mobile.cmmn.selectCommonCodeList";
	
		return list(QueryID, paramMap);

	}
	
	/*로그인 정보 담아두기*/
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectSanctnList(Map paramMap) throws Exception{
		
		String QueryID="";

			QueryID="mobile.cmmn.selectSanctnList";
	
		return list(QueryID, paramMap);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq002Query(Map<String,String> map) throws Exception{

		String searchUserSn = "";
		searchUserSn = map.get("searchUserSn")== null? "" :map.get("searchUserSn") ;
		
		String QueryID="";
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);

		if(!"".equals(searchUserSn)){
			QueryID="mobile.service.reqst.selectReq002OnlyQuery";
		}else{
			QueryID="mobile.service.reqst.selectReq002Query";
		}
	
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq004Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.reqst.selectReq004Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq004DetailQuery(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.service.reqst.selectReq004DetailQuery";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq010Query(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq010Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq010DetailQuery(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq010DetailQuery";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq043DetailQuery(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq043DetailQuery";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq013Query(Map<String,String> map)throws Exception {

		String searchUserSn = "";
		searchUserSn = map.get("searchUserSn")== null? "" :map.get("searchUserSn") ;
		
		String QueryID="";
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		

		if(!"".equals(searchUserSn)){
			QueryID="mobile.service.result.selectReq013OnlyQuery";
		}else{
			QueryID="mobile.service.result.selectReq013Query";
		}

		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq045Query(Map<String,String> map)throws Exception {

		String searchUserSn = "";
		searchUserSn = map.get("searchUserSn")== null? "" :map.get("searchUserSn") ;
		
		String QueryID="";
		

		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		
		if(!"".equals(searchUserSn)){
			QueryID="mobile.service.result.selectReq045OnlyQuery";
		}else{
			QueryID="mobile.service.result.selectReq045Query";
		}

		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq006Query(Map<String,String> map)throws Exception {

		String searchUserSn = "";
		searchUserSn = map.get("searchUserSn")== null? "" :map.get("searchUserSn") ;
		
		String QueryID="";
		
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		

		if(!"".equals(searchUserSn)){
			QueryID="mobile.service.result.selectReq006OnlyQueryList";
		}else{
			QueryID="mobile.service.result.selectReq006QueryList";
		}
	
		return list(QueryID, map);

	}
	
	
	/*로그인 정보 담아두기*/
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> loginSessionContainer(Map<String,String> map)throws Exception {
		
		String QueryID="";

			QueryID="mobile.service.common.loginSessionContainer";
	
		return list(QueryID, map);

	}
	
	
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq014Query(Map<String,String> map)throws Exception {

		String searchUserSn = "";
		searchUserSn = map.get("searchUserSn")== null? "" :map.get("searchUserSn") ;
		
		String QueryID="";
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		

		if(!"".equals(searchUserSn)){
			QueryID="mobile.service.dsnf.selectReq014OnlyQuery";
		}else{
			QueryID="mobile.service.dsnf.selectReq014Query";
		}

		return list(QueryID, map);

	}
	
	/*업무별 마지막 번호 가져오기*/
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectEndNo(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.cmmn.selectEndNo";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq017Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq017Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq017DetailQuery(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq017DetailQuery";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq040Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq040Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq040DetailQuery(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq040DetailQuery";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq041Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq041Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq041DetailQuery(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq041DetailQuery";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq022Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq022Query";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq023Query(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq023Query";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq024Query(Map<String,String> map)throws Exception {
		
		//http://211.47.133.100:8086/index.do?paramTarget=REQ024&searchOffCd=20&searchRecNo=14011233

		
		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq024Query";
		
		return list(QueryID, map);

	}
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq024DetailQuery(Map<String,String> map) throws Exception{
		
		//http://211.47.133.100:8086/index.do?paramTarget=REQ024&searchOffCd=20&searchRecNo=14011233
		String QueryID="";
	
		QueryID="mobile.service.dsnf.selectReq024DetailQuery";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq011Query(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.cmmn.selectReq011Query";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq012Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq012Query";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq039Query(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq039Query";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq025Query(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.cmmn.selectReq025Query";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq026Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.cmmn.selectReq026Query";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq027Query(Map<String,String> map)throws Exception {
		
		
		String searchType = "";
		searchType = map.get("searchType")== null? "" :map.get("searchType") ;
		
		String QueryID="";
		
		/*searchType : 020 긴급제한  010 : 수입금지*/
			
		if("020".equals(searchType)){
			QueryID="mobile.service.result.selectReq027_020Query";
		}else if("010".equals(searchType)){
			QueryID="mobile.service.result.selectReq027_010Query";
		}else if("000".equals(searchType)){
			QueryID="mobile.service.result.selectReq027_000Query";
		}
		
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq029Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq029Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq029DetailQuery(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq029DetailQuery";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq029QuranQuery(Map<String,String> map)throws Exception {
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq029QuranQuery";
		return list(QueryID, map);
	}
	
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq030Query(Map<String,String> map)throws Exception {
		
		String QueryID="";
		
		//String 
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		
		QueryID="mobile.service.result.selectReq030Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq016Query(Map<String,String> map)throws Exception {
		
		String QueryID="";
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		
		QueryID="mobile.service.dsnf.selectReq016Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq032Query(Map<String,String> map)throws Exception {
		
		String QueryID="";
		
		QueryID="mobile.cmmn.selectReq032Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq019Query(Map<String,String> map)throws Exception {
		
		String QueryID="";
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		
		QueryID="mobile.service.result.selectReq019Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq034Query(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.dsnf.selectReq034Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq034DetailQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.dsnf.selectReq034DetailQuery";
		return list(QueryID, map);
	}
	
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq020Query(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq020Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq020DetailQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq020DetailQuery";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq020LabQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq020LabQuery";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq020DbyhsQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq020DbyhsQuery";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq020DsnfQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq020DsnfQuery";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq020DsuseQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq020DsuseQuery";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq020ItemQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq020ItemQuery";
		return list(QueryID, map);
	}
	
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq036Query(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq036Query";
		return list(QueryID, map);
	}
	
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq036DetailQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq036DetailQuery";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq036QuranQuery(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq036QuranQuery";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq046Query(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq046Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")	
	public void insertReq005Query(List<Map> map) throws Exception{
		
		
		for( Map vo : map ){
			insert("mobile.service.reqst.insertReq005Query",vo);
		}
		
	}
	
	@SuppressWarnings("unchecked")	
	public void insertReq009Query(Map<String,String> map,List<Map<String,String>> dMap,int endNo , List<Map<String,String>> fileList) throws Exception{
		
		/*mMap : 마스터  dMap : 디테일*/
		String regType = "";
		
		String offCd = "";
		offCd = map.get("offCd");
		Map<String,String> quranMap = new HashMap<String, String>();
		String quranNamCd1 ="";
		String quranNamCd2 ="";
		String docScrtySe ="";
		
		insert("mobile.service.result.insertReq009ResultQuery",map); /*검역결과저장*/
		insert("mobile.service.result.insertStatus_t",map); /*문서유통 저장*/
		
		
		/*서류보완완료*/
		docScrtySe = map.get("passResrveReasonCd");
		
		if("342001".equals(docScrtySe))
		{
			insert("mobile.service.result.insertscrtyDetail",map);
		}		
		
		
		quranNamCd1 = map.get("quranCd1") ==null ? "" : map.get("quranCd1");
		quranNamCd2 = map.get("quranCd2") ==null ? "" : map.get("quranCd2");
		/*만약 검역관추가가 없는 경우 로그인 검역관 저장*/
		if(!"".equals(quranNamCd1))
		{
			
			quranMap.put("quranNamCd",quranNamCd1);
			quranMap.put("quranSeq","1");
			quranMap.put("resOffCd",map.get("resOffCd"));
			quranMap.put("resNo",map.get("resNo"));
			quranMap.put("updNamCd",map.get("updNamCd"));
			quranMap.put("regNamCd",map.get("regNamCd"));
			insert("mobile.service.result.insertReq009QuranQuery",quranMap);
		
		}else if("".equals(quranNamCd1)){
			
			quranNamCd1 = map.get("updNamCd"); /*로그인 검역관 Sn*/
			quranMap.put("quranNamCd",quranNamCd1);
			quranMap.put("quranSeq","1");
			quranMap.put("resOffCd",map.get("resOffCd"));
			quranMap.put("resNo",map.get("resNo"));
			quranMap.put("updNamCd",map.get("updNamCd"));
			quranMap.put("regNamCd",map.get("regNamCd"));
			insert("mobile.service.result.insertReq009QuranQuery",quranMap);
			
		}
		
		if(!"".equals(quranNamCd2))
		{
			quranMap.put("quranNamCd",quranNamCd2);
			quranMap.put("quranSeq","2");
			quranMap.put("resOffCd",map.get("resOffCd"));
			quranMap.put("resNo",map.get("resNo"));
			quranMap.put("updNamCd",map.get("updNamCd"));
			quranMap.put("regNamCd",map.get("regNamCd"));
			insert("mobile.service.result.insertReq009QuranQuery",quranMap);
		}
		
		
		
		
		if( !map.isEmpty()){
			
			regType = map.get("regType");
		}

		
		for( Map vo : dMap ){
			insert("mobile.service.result.insertReq009ResultDetailQuery",vo);
			insert("mobile.service.result.insertResultLog",vo); /*검역결과log저장*/
		}
		
		
	//검역결과번호 최종번호 업데이트

		if( endNo > 0){
			
			Map<String,String> newResNoMap =  new HashMap<String,String>();
			
			endNo = endNo + 1;
			
			newResNoMap.put("offCd", offCd);
			newResNoMap.put("noCd", "322002");
			newResNoMap.put("endNo", String.valueOf(endNo));
			
			//try {
				mergeEndNo(newResNoMap);
			//} catch (Exception e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
			//}
			
		}
		
		//파일저장
		
		if(fileList !=null){
			for( Map<String,String> file : fileList){
				insert("mobile.cmmn.insertFile",file); 
			}
		}
		
		
	}
	
	
	@SuppressWarnings("unchecked")	
	public void insertFileReq052Query( List<Map<String,String>> fileList) throws Exception{
		
		/*mMap : 마스터  dMap : 디테일*/
		
		
		//파일저장
		
		if(fileList !=null){
			for( Map<String,String> file : fileList){
				insert("mobile.cmmn.insertFile",file); 
			}
		}
		
		
	}
	
	
	@SuppressWarnings("unchecked")	
	public void insertReq047Query(Map<String,String> map,List<Map<String,String>> dMap,int endNo,List<Map<String,String>> fileList) throws Exception{
		
		/*mMap : 마스터  dMap : 디테일*/
		String regType = "";
		
		String offCd = "";
		offCd = map.get("offCd");
		Map<String,String> quranMap = new HashMap<String, String>();
		String quranNamCd1 ="";
		String quranNamCd2 ="";
		String docScrtySe ="";
		
		insert("mobile.service.result.insertReq047ResultQuery",map); /*검역결과저장*/
		
		insert("mobile.service.result.insertResultLog",map); /*검역결과log저장*/
		
		
		/*서류보완완료*/
		docScrtySe = map.get("passResrveReasonCd");
		
		if("342001".equals(docScrtySe))
		{
			insert("mobile.service.result.insertscrtyDetail",map);
		}		
		
		
		quranNamCd1 = map.get("quranCd1") ==null ? "" : map.get("quranCd1");
		quranNamCd2 = map.get("quranCd2") ==null ? "" : map.get("quranCd2");
		/*만약 검역관추가가 없는 경우 로그인 검역관 저장*/
		if(!"".equals(quranNamCd1))
		{
			
			quranMap.put("quranNamCd",quranNamCd1);
			quranMap.put("quranSeq","1");
			quranMap.put("resOffCd",map.get("resOffCd"));
			quranMap.put("resNo",map.get("resNo"));
			quranMap.put("updNamCd",map.get("updNamCd"));
			quranMap.put("regNamCd",map.get("regNamCd"));
			insert("mobile.service.result.insertReq047QuranQuery",quranMap);
		
		}else if("".equals(quranNamCd1)){
			
			quranNamCd1 = map.get("updNamCd"); /*로그인 검역관 Sn*/
			quranMap.put("quranNamCd",quranNamCd1);
			quranMap.put("quranSeq","1");
			quranMap.put("resOffCd",map.get("resOffCd"));
			quranMap.put("resNo",map.get("resNo"));
			quranMap.put("updNamCd",map.get("updNamCd"));
			quranMap.put("regNamCd",map.get("regNamCd"));
			insert("mobile.service.result.insertReq047QuranQuery",quranMap);
			
		}
		
		if(!"".equals(quranNamCd2))
		{
			quranMap.put("quranNamCd",quranNamCd2);
			quranMap.put("quranSeq","2");
			quranMap.put("resOffCd",map.get("resOffCd"));
			quranMap.put("resNo",map.get("resNo"));
			quranMap.put("updNamCd",map.get("updNamCd"));
			quranMap.put("regNamCd",map.get("regNamCd"));
			insert("mobile.service.result.insertReq047QuranQuery",quranMap);
		}
		
		
		
		
		if( !map.isEmpty()){
			
			regType = map.get("regType");
		}

		
		for( Map vo : dMap ){
			insert("mobile.service.result.insertReq047ResultDetailQuery",vo);
		}
		
		
	//검역결과번호 최종번호 업데이트

		if( endNo > 0){
			
			Map<String,String> newResNoMap =  new HashMap<String,String>();
			
			endNo = endNo + 1;
			
			newResNoMap.put("offCd", offCd);
			newResNoMap.put("noCd", "322002");
			newResNoMap.put("endNo", String.valueOf(endNo));
			
			//try {
				mergeEndNo(newResNoMap);
			//} catch (Exception e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
			//}
			
		}
		
		//파일저장

		if(fileList !=null){
			for( Map<String,String> file : fileList){
				insert("mobile.cmmn.insertFile",file); 
			}
		}
		
		
	}
	

	/*일괄결과등록 저장*/
	
	@SuppressWarnings("unchecked")	
	public void insertReq037Query(List<Map<String,String>> mList,List<Map<String,String>> dList,int endNo) throws Exception{
		
		/*mMap : 마스터  dMap : 디테일*/
		String offCd = "";
		Map<String,String> quranMap = new HashMap<String, String>();
		String quranNamCd1 ="";
		String quranNamCd2 ="";
		String docScrtySe="";
		
		for( Map<String,String> vo : mList ){
			insert("mobile.service.result.insertReq009ResultQuery",vo);
			offCd = vo.get("offCd");
			
			quranNamCd1 = vo.get("quranCd1") ==null ? "" : vo.get("quranCd1");
			quranNamCd2 = vo.get("quranCd2") ==null ? "" : vo.get("quranCd2");
			/*만약 검역관추가가 없는 경우 로그인 검역관 저장*/
			if(!"".equals(quranNamCd1))
			{
				
				quranMap.put("quranNamCd",quranNamCd1);
				quranMap.put("quranSeq","1");
				quranMap.put("resOffCd",vo.get("resOffCd"));
				quranMap.put("resNo",vo.get("resNo"));
				quranMap.put("updNamCd",vo.get("updNamCd"));
				quranMap.put("regNamCd",vo.get("regNamCd"));
				insert("mobile.service.result.insertReq009QuranQuery",quranMap);
			
			}else if("".equals(quranNamCd1)){
				
				quranNamCd1 = vo.get("updNamCd"); /*로그인 검역관 Sn*/
				quranMap.put("quranNamCd",quranNamCd1);
				quranMap.put("quranSeq","1");
				quranMap.put("resOffCd",vo.get("resOffCd"));
				quranMap.put("resNo",vo.get("resNo"));
				quranMap.put("updNamCd",vo.get("updNamCd"));
				quranMap.put("regNamCd",vo.get("regNamCd"));
				insert("mobile.service.result.insertReq009QuranQuery",quranMap);
				
			}
			
			System.out.println("quranNamCd2 :"+quranNamCd2);
			
			if(!"".equals(quranNamCd2))
			{
				quranMap.put("quranNamCd",quranNamCd2);
				quranMap.put("quranSeq","2");
				quranMap.put("resOffCd",vo.get("resOffCd"));
				quranMap.put("resNo",vo.get("resNo"));
				quranMap.put("updNamCd",vo.get("updNamCd"));
				quranMap.put("regNamCd",vo.get("regNamCd"));
				insert("mobile.service.result.insertReq009QuranQuery",quranMap);
			}
			
			/*서류보완완료*/
			docScrtySe = vo.get("passResrveReasonCd");
			
			if("342001".equals(docScrtySe))
			{
				insert("mobile.service.result.insertscrtyDetail",vo);
			}			
			
		}
		
		for( Map<String,String> vo : dList ){
			insert("mobile.service.result.insertReq009ResultDetailQuery",vo);
		}
		
		
	//검역결과번호 최종번호 업데이트

		if( endNo > 0){
			
			Map<String,String> newResNoMap =  new HashMap<String,String>();
			
			newResNoMap.put("offCd", offCd);
			newResNoMap.put("noCd", "322002");
			newResNoMap.put("endNo", String.valueOf(endNo));
			
			//try {
				mergeEndNo(newResNoMap);
			//} catch (Exception e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
			//}
			
		}
		
		
	}
	
	
	@SuppressWarnings("unchecked")	
	public void insertReq015Query(Map<String,String> map,List<Map<String,String>> dMap,int endNo,List<Map<String,String>> fileList) throws Exception{
		
		/*mMap : 마스터  dMap : 디테일*/
		
		
		insert("mobile.service.dsnf.insertReq015Query",map);
		
	
		String dsnfResOffCd="";
		for( Map<String,String> vo : dMap ){
			insert("mobile.service.dsnf.insertReq015DetailQuery",vo);
			
			dsnfResOffCd = (String)vo.get("dsnfResOffCd");
			
		}
		

		if( endNo > 0){
			
			Map<String,String> newResNoMap =  new HashMap<String,String>();
			
			newResNoMap.put("offCd", dsnfResOffCd);
			newResNoMap.put("noCd", "322004");
			newResNoMap.put("endNo", String.valueOf(endNo));
			
			//try {
				this.mergeEndNo(newResNoMap);
			//} catch (Exception e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
			//}
			
		}
		
		if(fileList !=null){
			for( Map<String,String> file : fileList){
				insert("mobile.cmmn.insertDsnfFile",file); 
			}
		}
		
	}
	
	
	
	@SuppressWarnings("unchecked")	
	public void insertReq035Query(Map<String,String> map,int endNo) throws Exception{
		
		/*mMap : 마스터  dMap : 디테일*/
		
		String offCd="";
		String ediYn="";
		
		insert("mobile.service.result.insertReq035Query",map);
		
		offCd = map.get("offCd");
				
		
		//결재번호 최종번호 업데이트
		
		if( endNo > 0){
			
			
			Map<String,String> newResNoMap =  new HashMap<String,String>();
			
			newResNoMap.put("offCd", offCd);
			newResNoMap.put("endNo", String.valueOf(endNo));
			
		//	try {
				
				insertSanctnMaxEndNo(newResNoMap); /*신규 결재번호 업데이트*/
				
			//} catch (Exception e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
			//}
			
		}
		
	}
	
	
	@SuppressWarnings("unchecked")	
	public void insertReq038Query(List<Map<String,String>> dMap,int endNo) throws Exception{
		
		/*mMap : 마스터  dMap : 디테일*/		
		String offCd="";
		
		for( Map<String,String> vo : dMap ){
			insert("mobile.service.result.insertReq035Query",vo);
			
			offCd = (String)vo.get("offCd");	
		}
		
		//결재번호 최종번호 업데이트
		
		if( endNo > 0){
			
			Map<String,String> newResNoMap =  new HashMap<String,String>();
			
			newResNoMap.put("offCd", offCd);
			newResNoMap.put("endNo", String.valueOf(endNo));
			
			//try {
				
				this.insertSanctnMaxEndNo(newResNoMap); /*신규 결재번호 업데이트*/
				
			//} catch (Exception e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
		//	}
			
		}
		
	}
	
	@SuppressWarnings("unchecked")	
	public void insertReq049Query(List<Map<String,String>> dMap) throws Exception{
				
		for( Map<String,String> vo : dMap ){
			insert("mobile.service.result.insertReq049Query",vo);
		}
	}
	
	@SuppressWarnings("unchecked")	
	public void deleteReq050Query(Map<String,String> map) throws Exception{
		
		update("mobile.service.result.deleteReq050Query", map);
	}
	
	public void mergeEndNo(Map<String,String> map )throws Exception{
		update("mobile.cmmn.mergeEndNo", map);
	}
	
	public void insertSanctnMaxEndNo(Map<String,String> map )throws Exception{
		update("mobile.service.result.insertSanctnMaxEndNo", map);
	}
	
	public List<Map<String,String>> selectSanctnMaxEndNo(String offCd )throws Exception{
		
		return list("mobile.service.result.selectSanctnMaxEndNo", offCd);
	}
	

	/*수출검역대기조회*/
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq042Query(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		String searchSdate = map.get("searchSdate") ==null ? "": map.get("searchSdate").replace("-", "");
		String searchEdate = map.get("searchEdate") ==null ? "": map.get("searchEdate").replace("-", "");
		
		map.put("searchSdate", searchSdate);
		map.put("searchEdate", searchEdate);
		
		QueryID="mobile.service.result.selectReq042Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")	
	public List<Map<String,String>> selectReq044Query(Map<String,String> map) throws Exception{
		
		String QueryID="";
		
		QueryID="mobile.service.result.selectReq044Query";
		return list(QueryID, map);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq048Query(Map<String,String> map) throws Exception{

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq048Query";
		
		return list(QueryID, map);

	}
	
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectReq0048DetailQuery(Map<String,String> map)throws Exception {

		String QueryID="";
	
		QueryID="mobile.service.result.selectReq0048DetailQuery";
		
		return list(QueryID, map);

	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectFileMaxId(Map<String,String> map)throws Exception {
		
		List<Map<String,String>> fileIdList = list("mobile.cmmn.selectFileIdFromResNo", map);
		if( null == fileIdList || fileIdList.size() == 0){
			fileIdList = list("mobile.cmmn.selectFileMaxId", map);
		}
		return fileIdList;
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectDsnfFileMaxId(Map<String,String> map)throws Exception {
		
		List<Map<String,String>> fileIdList = list("mobile.cmmn.selectFileIdFromDsnfNo", map);
		if( null == fileIdList || fileIdList.size() == 0){
			fileIdList = list("mobile.cmmn.selectFileMaxId", map);
		}
		return fileIdList;
	}
	

	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectFileList(Map<String,String> map)throws Exception {
		return list("mobile.cmmn.selectFileList", map);
	}
	
	public void updateFileId(Map<String,String> map)throws Exception {
		update("mobile.cmmn.updateReqstFileId", map);
	}
	
	public void deleteFile(Map<String,String> map)throws Exception {
		delete("mobile.cmmn.deletetFile", map);
	}
	
	@SuppressWarnings("unchecked")
	public List<Map<String,String>> selectExportYearList() throws Exception{

		String QueryID="";
	
		QueryID="mobile.cmmn.selectExportYearList";
		
		return list(QueryID,"");

	}
	
		
}
